package com.ruoyi.web.pojo.vo.insect;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDate;
import java.util.List;

@Data
public class InsectAnalysisCountVO {

    @ApiModelProperty(value = "当前年历史数据")
    private List<InsectAnalysisVO> currentYear;

    @ApiModelProperty(value = "上一年历史数据")
    private List<InsectAnalysisVO> previousYear;

    @ApiModelProperty(value = "当前年始见时间")
    private String currentFirst;

    @ApiModelProperty(value = "当前年始见数据")
    private Integer currentFirstNum;

    @ApiModelProperty(value = "上一年始见时间")
    private String previousFirst;

    @ApiModelProperty(value = "上一年始见数据")
    private Integer previousFirstNum;

    @ApiModelProperty(value = "上一年始见时间差值")
    private Integer previousSubtractFirst;

    @ApiModelProperty(value = "常年始见时间 - 一年的第n天")
    private Integer beforeFirst;

    @ApiModelProperty(value = "常年始见时间差值")
    private Integer beforeSubtractFirst;

    @ApiModelProperty(value = "当前高峰时间")
    private String currentPeak;

    @ApiModelProperty(value = "当前高峰数据")
    private Integer currentPeakNum;

    @ApiModelProperty(value = "上一年高峰时间")
    private String previousPeak;

    @ApiModelProperty(value = "上一年高峰数据")
    private Integer previousPeakNum;

    @ApiModelProperty(value = "上一年高峰数量差值")
    private Integer previousSubtractPeak;

//    @ApiModelProperty(value = "常年高峰时间")
//    private String beforePeak;

    @ApiModelProperty(value = "常年高峰数据")
    private Integer beforePeakNum;

    @ApiModelProperty(value = "常年高峰数量差值")
    private Integer beforeSubtractPeak;

    @ApiModelProperty(value = "当前年总计")
    private Integer currentSum;

    @ApiModelProperty(value = "上一年总计")
    private Integer previousSum;

    @ApiModelProperty(value = "常年平均")
    private Integer beforeAvg;

    @ApiModelProperty(value = "上一年总计差值")
    private Integer previousSubtractSum;

    @ApiModelProperty(value = "常年平均差值")
    private Integer beforeSubtractSum;

    /**
     * @desc  计算差值
     * @author fwx 2024/3/12 17:09
     **/
    public void subtract(){

        //和上一年始见期差值
        if(currentFirst != null && previousFirst != null){
            Integer currentFirstVal = LocalDate.parse(currentFirst).getDayOfYear();
            Integer previousFirstVal = LocalDate.parse(previousFirst).getDayOfYear();

            this.previousSubtractFirst = currentFirstVal - previousFirstVal;
        }

        //和常年始见期差值
        if(currentFirst != null && beforeFirst != null){
            Integer currentFirstVal = LocalDate.parse(currentFirst).getDayOfYear();
            this.beforeSubtractFirst = currentFirstVal - beforeFirst;
        }

        //和上一年峰值差值
        if(currentPeakNum != null && previousPeakNum != null){
            this.previousSubtractPeak = currentPeakNum - previousPeakNum;
        }

        //和常年峰值差值
        if(currentPeakNum != null && beforePeakNum != null){
            this.beforeSubtractPeak = currentPeakNum - beforePeakNum;
        }

        //和上一年总计差值
        if(currentSum != null && previousSum != null){
            this.previousSubtractSum = currentSum - previousSum;
        }

        //和常年总计平均的差值
        if(currentSum != null && beforeAvg != null){
            this.beforeSubtractSum = currentSum - beforeAvg;
        }

    }

}
